#!/bin/bash

# 克隆YOLOv8的Git仓库
git clone https://github.com/ultralytics/ultralytics.git ~/yolov8
chown -R $(whoami):$(whoami) ~/yolov8
cd ~/yolov8

# 创建并激活虚拟环境
python3 -m venv amdgpuyolo
source amdgpuyolo/bin/activate

# 更新pip
pip3 install --upgrade pip

# 安装ROCm支持的PyTorch版本
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.0

# 安装YOLOv8的依赖项
pip3 install cython matplotlib tensorboard

if [ ! -f "requirements.txt" ]; then
    cat > "requirements.txt" << EOF
matplotlib>=3.3.0
opencv-python>=4.6.0
pillow>=7.1.2
pyyaml>=5.3.1
requests>=2.23.0
scipy>=1.4.1
torch>=1.8.0
torchvision>=0.9.0
tqdm>=4.64.0
psutil
py-cpuinfo
thop>=0.1.1
pandas>=1.1.4
seaborn>=0.11.0
ipython
check-manifest
pre-commit
pytest
pytest-cov
coverage[toml]
mkdocs-material>=9.5.9
mkdocstrings[python]
mkdocs-jupyter
mkdocs-redirects
mkdocs-ultralytics-plugin>=0.0.44
EOF
    echo "requirements.txt file created successfully."
else
    echo "requirements.txt file already exists."
fi

# 安装YOLOv8
pip3 install -r requirements.txt
pip3 install yolov8

echo "YOLOv8 installation completed."